using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Joy.Erp.BasicArchives.Core.Filters;
using System.Collections.Generic;

namespace Joy.Erp.BasicArchives.ItemMasters
{
    [RemoteService(Name = BasicArchivesRemoteServiceConsts.RemoteServiceName)]
    [Area(BasicArchivesRemoteServiceConsts.ModuleName)]
    [ControllerName("BomMaster")]
    [Route("api/basic-archives/bom-master")]
    public partial class BomMasterController : BasicArchivesController, IBomMasterAppService
    {
        protected IBomMasterAppService BomMasterAppService => LazyServiceProvider.LazyGetRequiredService<IBomMasterAppService>();

        [HttpGet]
        [Route("{id}")]
        public Task<BomMasterDto> GetAsync(Guid id)
        {
            return BomMasterAppService.GetAsync(id);
        }

        [HttpGet]
        [Route("child/{id}")]
        public Task<BomComponentDto> GetChildAsync(Guid id)
        {
            return BomMasterAppService.GetChildAsync(id);
        }

        [HttpGet]
        [Route("find")]
        public Task<BomMasterDto> FindAsync(string filter)
        {
            return BomMasterAppService.FindAsync(filter);
        }

        [HttpGet]
        [Route("find-by-source-key")]
        public Task<BomMasterDto> FindBySourceKeyAsync(string sourceKey, string sourceType)
        {
            return BomMasterAppService.FindBySourceKeyAsync(sourceKey, sourceType);
        }

        [HttpGet]
        public Task<PagedResultDto<BomMasterDto>> GetListAsync(FilterRequestDto input)
        {
            return BomMasterAppService.GetListAsync(input);
        }

        [HttpPost]
        [Route("query")]
        public Task<PagedResultDto<BomMasterDto>> QueryAsync(FilterGroupRequestDto input)
        {
            return BomMasterAppService.QueryAsync(input);
        }

        [HttpPost]
        [Route("query-children")]
        public Task<PagedResultDto<BomComponentDto>> QueryChildrenAsync(FilterGroupRequestDto input)
        {
            return BomMasterAppService.QueryChildrenAsync(input);
        }

        [HttpPost]
        public Task<BomMasterDto> CreateAsync(BomMasterCreateDto input)
        {
            return BomMasterAppService.CreateAsync(input);
        }

        [HttpPut]
        [Route("{id}")]
        public Task<BomMasterDto> UpdateAsync(Guid id, BomMasterUpdateDto input)
        {
            return BomMasterAppService.UpdateAsync(id, input);
        }

        [HttpPost]
        [Route("submit")]
        public Task<BomMasterDto> SubmitAsync(Guid id)
        {
            return BomMasterAppService.SubmitAsync(id);
        }

        [HttpPost]
        [Route("approve")]
        public Task<BomMasterDto> ApproveAsync(Guid id)
        {
            return BomMasterAppService.ApproveAsync(id);
        }

        [HttpPost]
        [Route("unapprove")]
        public Task<BomMasterDto> UnApproveAsync(Guid id)
        {
            return BomMasterAppService.UnApproveAsync(id);
        }

        [HttpDelete]
        [Route("{id}")]
        public Task DeleteAsync(Guid id)
        {
            return BomMasterAppService.DeleteAsync(id);
        }

        [HttpGet]
        [Route("get-leaf-children")]
        public Task<List<BomComponentDto>> GetLeafChildrenAsync(Guid itemMasterId)
        {
            return BomMasterAppService.GetLeafChildrenAsync(itemMasterId);
        }
    }
}